import * as types from '../mutation-types'

// initial state
const state = {
  formInfo: {},
  isCommonFormEdit: false
}

// getters
const getters = {
  getFormInfo: state => state.formInfo,
  getIsCommonFormEdit: state => state.isCommonFormEdit
}

// actions
const actions = {
  setFormInfo ({commit}, setForm) {
    commit(types.SET_FORM_DATA, setForm)
  },
  setIsCommonFormEdit ({commit}, setIsCommonFormEdit) {
    commit(types.SET_IS_FORM_DATA, setIsCommonFormEdit)
  }
}

// mutations
const mutations = {
  [types.SET_FORM_DATA] (state, formInfo) {
    state.formInfo = formInfo
  },
  [types.SET_IS_FORM_DATA] (state, isCommonFormEdit) {
    state.isCommonFormEdit = isCommonFormEdit
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
